import { useEffect, useState } from 'react'
import styles from '../css/resetPwd.module.css'
import { Button } from 'antd'
import { useNavigate } from 'react-router-dom'

export default function ResetSuccessful(){
    // 倒计时
    const [counter,setCounter]=useState(5)
    // 路由跳转
    const nav = useNavigate()
    useEffect(()=>{
        if(counter>0){
            let timer=setTimeout(()=>{
                setCounter(counter-1)
            },1000)
            return ()=>clearTimeout(timer)
        }else{
            nav('/login')
        }
    },[counter])
    return <>
        <div className={styles.box4}>
            <p className={styles.p2}>重置密码成功！</p>
            <p className={styles.p3}><span className={styles.span}>{counter}秒</span>之后自动跳转登录页</p>
            <Button className={styles.btn3} type='primary' onClick={()=>nav('/login')}>前往登录页</Button>
        </div>
    </>
}